const path = require('path');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

const dllPath = path.resolve(__dirname, './dll');

console.log('-----dllPath', dllPath);

/*
  react: 'React',
  'react-dom': 'ReactDOM',
  redux: 'Redux',
  'react-redux': 'ReactRedux',
  'react-router-dom': 'ReactRouterDOM',
  classnames: 'classnames',
*/

module.exports = {
  entry: {
    // 'React': ['react'],
    // 'ReactDOM': ['react-dom'],
    // 'Redux': ['redux'],
    // 'ReactRedux': ['react-redux'],
    // 'ReactRouterDOM': ['react-router-dom'],
    // 'classnames': ['classnames'],
    // 把  相关模块的放到一个单独的动态链接库
    vendorDll: [
      'moment',
      'lodash',
      'react-router',
      'redux-thunk',
      '@reduxjs/toolkit',
      '@ant-design/icons',
      // "@ant-design/icons",
      // "i18next",
      // "i18next-browser-languagedetector",
      // 'antd',
      // '@seeyon/syf',
      // '@seeyon/ui',
      // '@seeyon/ui-mobile',
      // '@seeyon/native-sdk',
      // '@seeyon/tools',
    ],
  },
  output: {
    filename: '[name].dll.js', // dll.js
    path: dllPath,
    library: '[name]',
  },
  plugins: [
    new CleanWebpackPlugin({
      // 清除之前的dll文件
      root: dllPath,
    }),
    new webpack.DllPlugin({
      name: '[name]',
      // manifest.json 描述动态链接库包含了哪些内容
      path: path.resolve(__dirname, './dll/[name].dll.manifest.json'),
      context: __dirname,
    }),
  ],
};
